//
//  ViewController.m
//  10506加法计算器
//
//  Created by student on 16/2/20.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField1;
@property (weak, nonatomic) IBOutlet UITextField *textField2;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UIView *view1;
@property (weak, nonatomic) IBOutlet UITextField *textField3;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)btnPressed:(id)sender {
    
    if ([self.textField3.text isEqualToString:@"+"]) {
        self.label.text=[NSString stringWithFormat:@"%i",[self.textField1.text intValue]+[self.textField2.text intValue]];
    }
    else if ([self.textField3.text isEqualToString:@"-"]){
         self.label.text=[NSString stringWithFormat:@"%i",[self.textField1.text intValue]-[self.textField2.text intValue]];
    }
    else if ([self.textField3.text isEqualToString:@"*"]){
        self.label.text=[NSString stringWithFormat:@"%i",[self.textField1.text intValue]*[self.textField2.text intValue]];
    }
    else if ([self.textField3.text isEqualToString:@"/"]){
        self.label.text=[NSString stringWithFormat:@"%i",[self.textField1.text intValue]/[self.textField2.text intValue]];
    }

    self.view1.backgroundColor=[UIColor colorWithRed:[self.textField1.text intValue]/255.0 green:[self.textField2.text intValue]/255.0 blue:[self.label.text intValue]/255.0 alpha:0.5];
    
}
- (IBAction)backTap:(id)sender {
    [self.view endEditing:YES];
}

@end
